package com.qujia.common.enums;

import java.util.HashMap;
import java.util.Map;

public enum PayTypeEnum {
//des里的空格是方便小票打印排版
    dzk("dzk","电子卡  "),
    pos("pos","pos机   "),
    wx("wx","微信支付"),
    xj("xj","现金    "),
    zfb("zfb","支付宝  "),
    yhk("yhk","银行卡  "),
    yzf("yzf","预支付  "),
    zkbzf("yzf","卡包支付"),
    def("",""),
    cdk("cdk","车队卡  "),
    dkq("dkq","实体卡  "),

    ;

    private String type;
    private String des;

    PayTypeEnum(String type, String des) {
        this.type = type;
        this.des = des;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des;
    }

    private static Map<String,PayTypeEnum> keyMap;

    public static PayTypeEnum getByType(String type) {
        if (keyMap == null) {
            HashMap<String, PayTypeEnum> map = new HashMap<>();
            for (PayTypeEnum value : values()) {
                map.put(value.getType(),value);
            }
            keyMap = map;
        }
        return keyMap.get(type);
    }

    public static PayTypeEnum getByType(String type, PayTypeEnum def) {
        PayTypeEnum typeEnum = getByType(type);
        return typeEnum == null ? def : typeEnum;
    }

}
